package com.focusai.efairy.ui.adapter.report;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.focusai.efairy.R;
import com.focusai.efairy.model.report.ReportNumberInfo;

import me.drakeet.multitype.ItemViewBinder;

/**
 * Created by luo_guangwen on 2017/9/22.
 */

public class ReportInfoViewBinder extends ItemViewBinder<ReportNumberInfo, ReportInfoViewBinder.ViewHolder> {
    //报表饼图的色值
    private Context mContext;
    public ReportInfoViewBinder(Context context) {
        this.mContext = context;
    }

    @NonNull
    @Override
    protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View root = inflater.inflate(R.layout.item_report_text_view, parent, false);
        ViewHolder viewHolder = new ViewHolder(root);
        return viewHolder;
    }

    @Override
    protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull ReportNumberInfo item) {
         holder.textDevTypeName.setText(mContext.getResources()
                 .getString(R.string.report_info,item.getData(),item.getWeiDianNum(),item.getNormalNum(),item.getWarningNum(),item.getTotalWarningNum()));
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        TextView textDevTypeName;

        ViewHolder(View itemView) {
            super(itemView);
            textDevTypeName = (TextView) itemView.findViewById(R.id.text_report_info);
        }

    }
}
